package com.yzd.learnjava.innerclasses.controller;

import java.util.ArrayList;

import com.yzd.learnjava.util.Print;

public class Controller {
	private ArrayList<Event> events = new ArrayList<Event>();
	public void addEvent(Event event) {
		events.add(event);
	}
	
	public void run() {
		Print.print("111");
		while(events.size() > 0) {
			//Print.print("22");
			for(Event event : new ArrayList<Event>(events)) {
				if(event.ready()) {
					Print.print(event);
					event.action();
					events.remove(event);
				}
			}
		}
	}
}
